<?php
/**
 * Created by PhpStorm.
 * User: spatra
 * Date: 15-1-7
 * Time: 下午9:19
 */

class Lesson_Resource extends Eloquent
{

    public function creater()
    {
        return $this->hasOne('User', 'id', 'creater_id');
    }

    public function lesson()
    {
        return $this->belongsTo('Lesson', 'lesson_id', 'id');
    }

    public static function getResourceDirectory()
    {
        return public_path(). '/lesson_resource/';
    }

    public static function getResourceRealPath(\Illuminate\Database\Eloquent\Model $resource)
    {
        return static::getResourceDirectory(). $resource['real_name'];
    }

    protected $touches = ['lesson'];

    protected $guarded = ['id'];

    protected $table = 'lesson_resources';
}